package book;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: a1227
 * Date: 2022-10-04
 * Time: 11:43
 */

//相当于一个书架，用于存放多本书籍，就是一个顺序表
public class BookList {
    //空间大小为10的Book数组
    private Book[] books = new Book[10];
    private int size;//计算当前所存放的书籍数

    //构造方法，默认一开始存放四大名著
    public BookList(){
        books[0] = new Book("三国演义","罗贯中","小说",50);
        books[1] = new Book("西游记","吴承恩","小说",50);
        books[2] = new Book("红楼梦","曹雪芹","小说",50);
        books[3] = new Book("水浒传","施耐庵","小说",50);
        this.size = 4;//当前数量
    }

    //返回下标为pos的书籍
    public Book getBook(int pos){

        return books[pos];
    }

    //放置一本书籍于pos位置
    public void setBook(int pos,Book book){

        books[pos] = book;
    }

    //获取当前大小
    public int getSize() {

        return size;
    }

    //修改当前大小
    public void setSize(int size) {

        this.size = size;
    }
}
